package com.diaohw.module.log.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.diaohw.module.log.mapper.RequestLogMapper;
import com.diaohw.module.log.obj.entity.RequestLog;
import com.diaohw.module.log.obj.query.LogQuery;
import com.diaohw.module.log.service.ExportService;
import com.diaohw.module.log.service.LogService;
import com.diaohw.module.log.service.export.ExcelHandle;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.util.List;

@Service
public class ExportImpl implements ExportService {

    @Resource
    private LogService logService;
    @Resource
    private RequestLogMapper requestLogMapper;
    @Resource
    private ExcelHandle excelHandle;

    @Override
    public void excel(LogQuery query) {
        LambdaQueryWrapper<RequestLog> wrapper = logService.createWrapper(query);
        List<RequestLog> list = requestLogMapper.selectList(wrapper);
        try {
            excelHandle.execute(list);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
